package kos.robert.loader;

import java.awt.font.TextAttribute;
import java.text.AttributedString;
import java.util.ArrayList;

public class Debug {
	private static int FPS;
	private static int sampleCount, sampleNumber =20;
	private static ArrayList<Long> list = new ArrayList<Long>();
	

	static public AttributedString getAttributedString (String s, TextAttribute a, Object o) {
		AttributedString as = new AttributedString(s);
		as.addAttribute(a, o);
		return as;		
	}

	static void update(long timePassed) {
		if (timePassed != 0) {
			list.add(timePassed);
			if(list.size()>sampleNumber) list.remove(0);
			int sum=0;
			for(long l:list){
				sum += l;
			}
			FPS = (1000* sampleNumber)/sum;
		}
	}

	static int getFPS() {
		return FPS;
	}
}
